package cn.itcast.service.cargo.impl;

import cn.itcast.dao.cargo.PackingDao;
import cn.itcast.domain.cargo.Packing;
import cn.itcast.service.cargo.PackingService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class PackingServiceImpl implements PackingService {
    @Autowired
    private PackingDao packingDao;
    @Override
    public void save(Packing packing) {
        packingDao.insertSelective(packing);
    }

    @Override
    public void update(Packing packing) {
        packingDao.updateByPrimaryKeySelective(packing);
    }

    @Override
    public PageInfo<Packing> findAll(String companyId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Packing> list = packingDao.selectByCompanyId(companyId);
        return new PageInfo<>(list,5);
    }


    @Override
    public void delete(String id) {
        packingDao.deleteByPrimaryKey(id);
    }

    @Override
    public Packing findById(String packingListId) {
       return packingDao.selectByPrimaryKey(packingListId);
    }
}
